/*
 * @Autor: 黄旗
 * @Date: 2021-11-11 10:08:45
 */
import util from '@/libs/util'
export default {
    namespaced: true,
    state: {
        patientjz: [],
        patientjd: [],
        callpatientjz: {
            id: '',
            type: 1,
            patient: {
                name: '',
                clinic_name: ''
            },
            audio_file: ''
        },
        callpatientjd: {
            id: '',
            type: 2,
            patient: {
                name: '',
                clinic_name: ''
            },
            audio_file: ''
        },
        projectList: [],
        queueInfusionScreen: 0
    },
    getters: {
        /**
         * @description 获取肌注列表
         * */
        getpatientjz: (state) => {
            return state.patientjz
        },
        /**
         * @description 获取静滴列表
         * */
        getpatientjd: (state) => {
            return state.patientjd
        },
        /**
         * @description 获取肌注叫号
         * */
        getcallpatientjz: (state) => {
            return state.callpatientjz
        },
        /**
         * @description 获取静滴叫号
         * */
        getcallpatientjd: (state) => {
            return state.callpatientjd
        },
        /**
         * @description 获取项目列表
         * */
        getprojectList: (state) => {
            return state.projectList
        },
        getqueueInfusionScreen: (state) => {
            return state.queueInfusionScreen
        }
    },
    mutations: {
        /**
         * @description 设置静滴、肌注列表
         * @param {Object} state vuex state
         * @param {Array} menu menu
         */
        Set_Patient (state, patient) {
            state.patientjz = patient.jz
            state.patientjd = patient.jd
        },
        Call_Patient (state, patient) {
            if (+patient.type === 1) state.callpatientjd = patient
            else state.callpatientjz = patient
        },
        Set_ProjectList (state, projectList) {
            state.projectList = projectList
        },
        queue_InfusionScreen (state, queueInfusionScreen) {
            state.queueInfusionScreen = queueInfusionScreen
        },
        remove_queueInfusionScreen (state) {
            if (+state.callpatientjd.id === +state.queueInfusionScreen) {
                state.callpatientjd.patient.name = ''
                state.callpatientjd.patient.clinic_name = ''
            } else if (+state.callpatientjz.id === +state.queueInfusionScreen) {
                state.callpatientjz.patient.name = ''
                state.callpatientjz.patient.clinic_name = ''
            }
        },
        remove_queueInfusionScreens (state, type) {
            if (type === 1) {
                state.callpatientjd.patient.name = ''
                state.callpatientjd.patient.clinic_name = ''
            } else if (type === 2) {
                state.callpatientjz.patient.name = ''
                state.callpatientjz.patient.clinic_name = ''
            }
        }
    },

    actions: {
        setPatient ({ commit }, patient) {
            commit('Set_Patient', patient);
        },
        callPatient ({ commit }, patient) {
            commit('Call_Patient', patient);
        },
        setprojectList ({ commit }, projectList) {
            commit('Set_ProjectList', projectList);
        },
        queueInfusionScreen ({ commit }, queueInfusionScreen) {
            commit('queue_InfusionScreen', queueInfusionScreen.id);
        }
    }
};
